package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.Student;
import com.qf.mapper.StudentMapper;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 10537
 * @version V1.0
 * @Date 2021/10/6 15:51
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<Student> findByPage(Integer page, Integer rows) {
        PageHelper.startPage(page,rows);
        List<Student> list= studentMapper.selectByClasses();
        PageInfo<Student> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void add(Student student) {
        int i = studentMapper.insert(student);
        if (i!=1){
            System.out.println("添加学生信息失败");
            throw new RuntimeException("添加学生信息失败");
        }
    }
}
